package com.scs.application.modules.upms.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Maps;
import com.scs.application.core.model.CommonResult;
import com.scs.application.core.mvc.controller.BaseBadgeController;
import com.scs.application.modules.upms.entity.OnlineUser;
import com.scs.application.modules.upms.service.OnlineUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

/**
 * @description:
 */
@RestController
@RequestMapping("/upms/badges")
public class BadgeController extends BaseBadgeController {

    @Autowired
    private OnlineUserService onlineUserService;

    @Override
    public CommonResult<Map<String, Object>> getCount() {
        int onlineUserCount = onlineUserService.count(Wrappers.<OnlineUser>query().gt("expire_time", new Date()));

        Map<String, Object> map = Maps.newHashMap();
        map.put("onlineUserCount", onlineUserCount);

        return CommonResult.ok("查询成功", map);
    }
}
